home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac: Not for Sale / Another.not.for.sale (Australia).iso / fade into you / getting there / Apps / MOO-1.7.6.src / inc / execute.h < prev    next >
Text File  |  1994-11-02  |  5KB  |  137 lines

  1. /******************************************************************************
  2.   Copyright (c) 1992 Xerox Corporation.  All rights reserved.
  3.   Portions of this code were written by Stephen White, aka ghond.
  4.   Use and copying of this software and preparation of derivative works based
  5.   upon this software are permitted.  Any distribution of this software or
  6.   derivative works must comply with all applicable United States export
  7.   control laws.  This software is made available AS IS, and Xerox Corporation
  8.   makes no warranty about the software, its performance or its conformity to
  9.   any specification.  Any person obtaining a copy of this software is requested
  10.   to send their name and post office or electronic mail address to:
  11.     Pavel Curtis
  12.     Xerox PARC
  13.     3333 Coyote Hill Rd.
  14.     Palo Alto, CA 94304
  15.     Pavel@Xerox.Com
  16.  *****************************************************************************/
  17.  
  18. #ifndef Execute_h
  19. #define Execute_h 1
  20.  
  21. #include "bytecodes.h"
  22. #include "config.h"
  23. #include "opcode.h"
  24. #include "options.h"
  25. #include "program.h"
  26. #include "structures.h"
  27.  
  28. typedef struct {
  29.   Program *prog;
  30.   Var     *rt_env;   /* same length as prog.var_names */
  31.   Var *base_rt_stack;
  32.   Var *top_rt_stack; /* the stack has a fixed size equal to prog.num_var_names;
  33.             top_rt_stack always points to next empty slot;
  34.             there is no need to check bounds! */  
  35.   unsigned pc;
  36.   unsigned error_pc;
  37.   Byte bi_func_pc;   /* next == 0 means a normal activation, which just
  38.             returns to the previous activation (caller verb).
  39.             next == 1, 2, 3, ... means the returned value should be
  40.             fed to the bi_func (as specified in bi_func_id) 
  41.             together with the next code. */
  42.   Byte bi_func_id;
  43.   void *bi_func_data;
  44.   Var    temp;         /* VM's temp register */
  45.  
  46.   /* verb information */
  47.   Objid this;
  48.   Objid player;
  49.   Objid progr;
  50.   Objid vloc;
  51.   const char *verb;
  52.   const char *verbname;
  53.   int debug;
  54.   
  55. } activation;
  56.  
  57. typedef activation    activation_stack[MAX_VERB_DEPTH];
  58.  
  59. extern void         free_activation(activation a, char data_too);
  60.  
  61. typedef struct {
  62.     activation_stack        activ_stack;
  63.     unsigned            top_activ_stack;
  64.     int                root_activ_vector;
  65.                                 /* root_activ_vector == MAIN_VECTOR
  66.                             means root activation is main_vector */
  67.     unsigned            func_id;
  68. } vmstruct;
  69.  
  70. typedef vmstruct       *vm;
  71.  
  72. #define alloc_data(size)   mymalloc(size, M_BI_FUNC_DATA)
  73. #define free_data(ptr)     myfree((void *) ptr, M_BI_FUNC_DATA)
  74.  
  75. /* call_verb will only return E_MAXREC, E_INVIND, E_VERBNF, E_TYPE (for args) 
  76.    or E_NONE.  the vm will only be changed if E_NONE is returned */
  77. extern enum error call_verb(Objid obj, const char *vname, Var args,
  78.                 int do_pass);
  79.  
  80. extern int     setup_activ_for_eval(Program *prog);
  81.  
  82. extern Var     do_forked_task(Program *prog, Var *rt_env, activation a,
  83.                    unsigned f_id);
  84. extern Var     do_input_task(Program *prog, Parse_Info *pi);
  85. extern Var    do_server_task(Objid this, const char *verb, Var args,
  86.                    Objid vloc, const char *verbname, Program *prog,
  87.                    Objid progr, int debug, Objid player,
  88.                    const char *argstr);
  89.  
  90. extern int    task_timed_out;
  91. extern void    abort_running_task(void);
  92. extern void     print_error_backtrace(const char *, int);
  93.  
  94. extern Var      resume_from_previous_vm(vm the_vm, Var v);
  95.  
  96. extern void     free_rt_env(Var *, unsigned);
  97. extern Var     *new_rt_env(unsigned);
  98.  
  99. extern void     write_activ(activation a);
  100. extern int    read_activ(FILE *f, activation *a, int which_vector);
  101.      
  102. #endif
  103.  
  104. /* $Log: execute.h,v $
  105.  * Revision 1.10  1992/10/23  23:03:47  pavel
  106.  * Added copyright notice.
  107.  *
  108.  * Revision 1.9  1992/10/21  03:02:35  pavel
  109.  * Converted to use new automatic configuration system.
  110.  *
  111.  * Revision 1.8  1992/10/17  20:29:09  pavel
  112.  * Changed return-type of read_activ() from char to int, for systems that use
  113.  * unsigned chars.
  114.  *
  115.  * Revision 1.7  1992/09/25  21:11:03  pjames
  116.  * Added error_pc to the activation data structure.
  117.  *
  118.  * Revision 1.6  1992/09/24  16:43:35  pavel
  119.  * Added `task_timed_out' to the interface.
  120.  *
  121.  * Revision 1.5  1992/09/02  18:42:25  pavel
  122.  * Fixed resume_from_previous_vm() to accept any MOO value as the resumption
  123.  * value, instead of just strings.
  124.  *
  125.  * Revision 1.4  1992/08/31  22:27:38  pjames
  126.  * Changed some `char *'s to `const char *'
  127.  *
  128.  * Revision 1.3  1992/08/10  17:44:28  pjames
  129.  * Moved several functions declarations to eval_env.h and eval_vm.h
  130.  *
  131.  * Revision 1.2  1992/07/27  18:01:45  pjames
  132.  * Changed name of ct_env to var_names
  133.  *
  134.  * Revision 1.1  1992/07/20  23:23:12  pavel
  135.  * Initial RCS-controlled version.
  136.  * */
  137.